<template>
  <el-form-item label-width="0px">
    <div class="w-full flex justify-between px-2 pb-1" >
      <label class="el-form-item__label -ml-2" style="width: 80px;">{{ config.label }}</label>
      <el-button @click="addArray"  size="small">添加</el-button>
    </div>
    <div class="mx-2 mb-2 bg-white p-2 shadow-md" v-for="(item,index) in config.value"  :key="index">
      <div  class="border-b border-gray-300 w-full flex justify-end pb-1" >
        <el-link type="danger" icon="el-icon-delete" :underline="false" @click="delArray(index)"></el-link>
      </div>
      <div class="py-2">
        <generate-field-form-item  v-for="(currentConfig,key) in item" :config="currentConfig" :key="key"></generate-field-form-item>
      </div>
    </div>
  </el-form-item>
</template>

<script>

export default {
  name: "generate-field-form-parse-array-object",
  props:{
    config:{
      type:Object
    }
  },
  methods:{
    addArray(){
      this.config.value.push(JSON.parse(JSON.stringify(this.config.__data_struct__)))
    },
    delArray(index){
      this.config.value.splice(index,1)
    }
  }
}
</script>

<style scoped>

</style>
